﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace NSX07
{
    public partial class HomeDefault : System.Web.UI.MasterPage
    {
         protected void Page_Load(object sender, EventArgs e)
        {
            // login with session
            if (Session["Authenticate"].ToString() == "Yes")
            {
                lblUsername.Text = "Hello " + Session["User"].ToString(); 
                lblUsername.Visible = true;
                lnbtnLogout.Visible = true;
                hlRegister.Visible = false;
                hlLogin.Visible = false;

                if (Session["Role"].ToString() == "admin")
                {
                    manaPCtrl.Visible = true;
                    manaCCtrl.Visible = true;
                }
                else
                {
                    manaPCtrl.Visible = false;
                    manaCCtrl.Visible = false;
                }
            }
            else
            {
                lblUsername.Visible = false;
                lnbtnLogout.Visible = false;
                hlRegister.Visible = true;
                hlLogin.Visible = true;
            }

            // end login//

          
        }

      

        protected void lnbtnLogout_Click(object sender, EventArgs e)
        {
            Session["Authenticate"] = "";
            Session["User"] = "";
            Session["Role"] = "";

            Response.Redirect("~/default.aspx");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
          
        }

        protected void txtKeySearch_TextChanged(object sender, EventArgs e)
        {
            string keyWord = txtKeySearch.Text.ToString();
            Button2.PostBackUrl = "search.aspx?name=%" + keyWord + "%";
        }

       

    }
    }

